#include <sstream>

#include "Application.h"
#include "NCenter.h"
#include "Observer.h"

#include "DXButtonView.h"
#include "DXImage.h"
#include "DX.h"

DXButtonView::DXButtonView( MRect rect, DXImage* image, DXImage* rollOverImage, std::wstring actionName ) : DXImageView( rect, image ), 
																					_dupImage( image ), 
																					_rollOverImage( rollOverImage ),
																					_actionName( actionName ),
																					pressAction( 0 )
{
	
}

DXButtonView::~DXButtonView( )
{
	delete pressAction;
}

void DXButtonView::update( )
{
	DXImageView::update();
}

void DXButtonView::track( bool isTrackOn )
{
	_image = ( isTrackOn ) ? _rollOverImage : _dupImage;
}

void DXButtonView::leftMouseDown( const IEvent& event )
{

	( *pressAction )( 0 );
}

void DXButtonView::setVisible( bool visible )
{
	if ( visible ) _image = _dupImage;
	View::setVisible( visible );
}

#ifdef _DEBUG
//
//std::wstring DXButtonView::description()
//{
//	std::wstring ret;
//	std::wostringstream st;
//	st << "DXButtonView:" << " x = " << rect().x() << " y = " << rect().y() << " w = " << rect().width() << " h = " << rect().height() << std::endl;
//	ret += st.str();
//	return ret;
//}

#endif